<?php
namespace app\admin\validate;
use think\Validate;
class Category extends Validate
{
    protected $rule =   [
        'name'  => 'require|max:25',
        'parent_id'   => 'number',
        'id' => 'number',
        'status' =>'number|in:-1,0,1',
        'listorder' =>'number' 
    ];

    protected $message  =   [
        'name.require' => '名称必须传递！',
        'name.max'     => '名称最多不能超过25个字符！',
        'status.number'  => '状态必须是数字',
        'status.in'  => '状态范围不合法',
         
    ];
    //使用场景
    protected $scene = [
    	'add' => ['name','parent_id','id'],//添加功能
    	'listorder' =>['id','listorder'],//排序
    	'status' => ['id','status']
    ];

}